﻿<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>经典DEMO</title>
  <script type="text/javascript" src="cicy/cicylib-all-debug.js"></script>
  <link rel="stylesheet" href="cicy/default/global.css" type="text/css"/>
  <link rel="stylesheet" href="cicy/default/ru_share.css" type="text/css"/>
<style>
	#northTab {position:absolute;bottom:0;}
	.demo-grid .g-grid-ct .cell {height:15px;}/* grid的高度设定 */
	.myform{width:98%;margin:5px;}/* 表格样式 */
	.myform .tbl-td{border:1px solid #444;}
	.myform .c1 {width:12%;background-color:#CCC;}
	.myform .c2 {width:20%;}
	.myform .c3 {width:25%;}
	.myform select {width:98%;}
</style>
</head>
<body>
</body>
</html>
<script>
	var vp = null;
	var gpara = '';
		CC.ready(function(){
			vp = new CC.ui.Viewport({
				layout:'border',
				title:'经典DEMO',
				lyCfg : {
					items : [
					 {ctype:'panel', height:70, 
					 	lyInf:{gap:1,dir:'north', collapsed:false}, 
					 	layout:'row',
					 	lyCfg:{items:[					 	 
					 	 {ctype:'tab', id:'northTab',
					 	 	selectionProvider:{selected:0},
					 	 	events : {selected : [ { cb : function(item){viewMenu(item);} } ]},
					 	 	layout:'tabitem',
					 	 	lyCfg:{
					 	 	 marginLeft:190,
					 	 	 items:
					 	 	  [ 
					 	 	   {id:'0',title: '我的主页',closeable: false },	
					 	 	   {id:'1',title: '车辆管理',closeable: false},
					 	 	   {id:'999',title: '组织管理',closeable: false},	
								 {id:'hr',title: '人事系统',closeable: false},
								 {id:'zy',title: '作业系统',closeable: false},
								 {id:'unfm',title: '配置系统',closeable: false}
						    ]
						  }
						 }
					   ]
					  }
					 },
					 
					 {ctype:'titlepanel', width:190, title:'功能菜单', lyInf:{split:true, dir:'west',collapsed: false}, maxW:300,
					 	layout:'border',
					 	css:'lnr lnb lnt',
					 	lyCfg:{items:
					 		[
					 	  	{id:'myTree',ctype:'tree', css:'lnb', 
					 	  	 events : {selected : [ { cb : function(item){viewMain(item);} } ]},
					 	  	 lyInf:{
					 	  	 	 dir:'center'}, 
					 	  		 rootCfg:{ expanded:true, title:''}
					 	  	},
					 	  	{ctype:'folder', height:200, css:'lnt',lyInf:{split:true,dir:'south',collapsed:false}, 
					 	  	 events : {selected : [ { cb : function(item){viewtest();} } ]},
					 	  	 array:
					 	  		[
						  			{title:'disabled item',icon:'iconRef'},
										{title:'粉红色',icon:'iconUser'},
										{title:'蓝色',icon:'iconEdit'},
										{title:'清除记录',icon:'iconLeaf'},
										{title:'粉红色',icon:'iconTabs'},
										{title:'蓝色',icon:'iconUser'},
										{title:'清除记录',icon:'iconEdit'}
	  	         		]
	  	         	}
					 	  ]
					 	}
					 },
					 {ctype:'panel', 
					 	css:'lnx',
					 	lyInf:{dir:'center'},
					  layout:'row',
					  id:'tabContent'
					 }
					]
				},
				showTo:document.body,
				destoryOnClose:true
			});
      vp.render();
      
	      
		});
		
function gDataProc(obj,dataType,data)
{
	if(data._s_msgid === 0){                    
        CC.util.ConnectionProvider.prototype.defaultDataProcessor.call(obj, dataType, data._s_lay);
    }else {
        CC.Util.alert('请求出现错误:'+data._s_msg);
    }           
}
function createCellData(cols, rows){
	var rs = [];
	for(var i=0;i<rows;i++){
		var cs = {array:[]};
		for(var j=0;j<cols;j++){
			cs.array.push({title:i+','+j});
		}
		rs.push(cs);
	}
	return rs;
}
function viewMenu(item)
{ 
	var myRoot = vp.byId('myTree').root;
	myRoot.setTitle(item.title);
	myRoot.clear();
	CC.Ajax.connect({
 		url :'/unfw/go?do=6&id='+item.id,
 		success : function(ajax){
         		var json = this.getJson();
         		myRoot.fromArray(json._s_lay);
         		},
 		failure : function(){alert('菜单数据错误.');}
 	});
}
function loadItemContent(item)
{ 
	
}
function viewMain(item)
{	
	vp.byId('tabContent').destroyChildren();
	CC.Ajax.connect({
 		url :'/unfw/go?do='+(item.id==undefined?item:item.id)+'&'+gpara,
 		success : function(ajax){
 				//alert(this.url);
         		var json = this.getJson();
         		if(json)
         		{
	         		var msgid = json._s_msgid;
	         		var msg = json._s_msg;
	         		var lay = json._s_lay;
	         		var data = json._s_data;// 预留exec
	         		//alert(objectType(data));
	         		//for(var item in data) alert(item+"--"+data[item]);
	         		var exe = json._s_exe;
	         		vp.byId('tabContent').destroyChildren();
	         		if(lay) vp.byId('tabContent').layout.fromArray(lay);
	         		eval(exe);
         		}else alert('没有数据');
          },
 		failure : function(){alert('页面数据错误.');}
 	}); 	
}			
function myfullData(tdata)
{   
	var data = tdata[0];
	for(var item in data)
	{		
		if(item=="0") continue;
		if(vp.byId(item)) vp.byId(item).setValue(data[item]);
	}
}	
function objectType(obj)
{

  var constructor = (String)(obj.constructor);
  var tokens = constructor.split(" ");

  for(var i=0; i<tokens.length; i++)
  {
    if(tokens[i].indexOf("function") != -1)
    {
      var end = tokens[i+1].indexOf("(");

      if(end == -1)
        return(tokens[i+1]);
      else
        return(tokens[i+1].substring(0, end));
    }
  }
}// END objectType
function viewtest()
{	
	vp.byId('tabContent').destroyChildren();
	CC.Ajax.connect({
 		url :'/unfw/go?do=52&if_d=-1',
 		success : function(ajax){
 				alert(this.url);
         		var json = this.getJson();
         		if(json)
         		{
	         		var msgid = json._s_msgid;
	         		var msg = json._s_msg;
	         		var lay = json._s_lay;
	         		var data = json._s_data;
	         		//alert(objectType(data));
	         		//for(var item in data) alert(item+"--"+data[item]);
	         		var exe = json._s_exe;
	         		vp.byId('tabContent').destroyChildren();
	         		if(lay) vp.byId('tabContent').layout.fromArray(lay);
	         		eval(exe);
         		}else alert('没有数据');
          },
 		failure : function(){alert('页面数据错误.');}
 	}); 	
}
</script>